<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>info</title>
    	<link href="css/mui.min.css" rel="stylesheet"/>
    	<script src="js/jquery-1.8.2.min.js"></script>
    	<script src="js/mui.min.js"></script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">评价</h1>
		</header>
		<div class="mui-content">
			<input type="hidden" name="pId" id="pId"  />
			<input type="hidden" name="supplierId" id="supplierId"  />
		    <div class="mui-content-padded">
				<div class="mui-input-row">
					<input type="text" id="name"  readonly>
				</div>
				<div class="mui-input-row" >  
					<p style="float: left;font-size: 15px; width: 10%; ">星级:</p>
					<label  style="float: left;line-height: 0; width: 20%; color:  red;" id='field-range-input' value='0'>0</label>
					<input style="float: left; width:70%;" type="range" id='field-range' value="0" min="0" max="5" />
				</div>
				<div  class="mui-input-row"><textarea rows="14" id="content" name="content" placeholder="评价内容" ></textarea>
				</div>
				<div class="mui-button-row">
					<button id="sub" onclick="sub();" class="mui-btn mui-btn-block mui-btn-primary addItemBtn">提交</button>
				</div>
			</div>
		</div>
		
		<script charset="UTF-8" type="text/javascript">
    	var $$=jQuery.noConflict();
    	mui.plusReady(function(){
			var self = plus.webview.currentWebview();
			var id = self.pId;
			var name = self.name;
			var supplierId = self.supplierId;
			document.getElementById("name").value=name;
			document.getElementById("pId").value=id;
			document.getElementById("supplierId").value=supplierId;
			
			var url = 'http://192.168.1.55:8080/Bidd/Json/m_GetProjectComment.action';
			var param = {"tmpProjectId" : id};
			console.log("info.xml 22222");
			mui.post(url,param,function(data){
				var jsonData = new Function("return"+data)();
				for (var o in jsonData) {
					document.getElementById("content").value=jsonData[o].content;
					document.getElementById("field-range").value=jsonData[o].starGrade;
					document.getElementById('field-range-input').innerHTML = jsonData[o].starGrade;
					$$("#sub").attr("disabled",true);
				}
			},"json");
    	});
    	function sub(){
    		var url = 'http://192.168.1.55:8080/Bidd/Json/m_UpdateProjectComment.action';
			var param = {"projectComment.projectId" : document.getElementById("pId").value ,"projectComment.starGrade"  : document.getElementById("starGrade").value, "projectComment.content"  : document.getElementById("content").value, "projectComment.supplierId" : document.getElementById("supplierId").value};
			
			mui.post(url,param,function(data){
				if(data == 1){
					$$("#sub").attr("disabled",true);
					mui.toast("提交成功！")
				}
			},"json");
    	}
    	
    	var rangeList = document.querySelectorAll('input[type="range"]');
	    for(var i=0,len=rangeList.length;i<len;i++){
	        rangeList[i].addEventListener('input',function(){
	            if(this.id.indexOf('field')>=0){
	                document.getElementById(this.id+'-input').innerHTML = this.value;
	            }else{
	                document.getElementById(this.id+'-val').innerHTML = this.value;
	            }
	            
	
	        });
	    }
	
	    document.getElementById('field-range-input').addEventListener('input',function(){
	        document.getElementById('field-range').value = this.value;
	    });
    	</script>
	</body>
</html>
